package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.SharePoolWeek;
import com.sc.nft.enums.AwardsTypeEnum;
import com.sc.nft.mapper.SharePoolWeekMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Objects;


@Slf4j
@Repository
public class SharePoolWeekDao extends ServiceImpl<SharePoolWeekMapper, SharePoolWeek> {

    public List<SharePoolWeek> getWaitSettleByTypeAndCollectionId(Long daoId, String yearWeek, AwardsTypeEnum awardsType, Long identityCollectionId, Long pushCollectionId) {
        LambdaQueryWrapper<SharePoolWeek> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(SharePoolWeek::getDaoId, daoId);
        wrapper.eq(SharePoolWeek::getYearWeek, yearWeek);
        wrapper.eq(SharePoolWeek::getAwardsType, awardsType);
        wrapper.eq(Objects.nonNull(identityCollectionId), SharePoolWeek::getIdentityCollectionId, identityCollectionId);
        wrapper.eq(Objects.nonNull(pushCollectionId), SharePoolWeek::getPushCollectionId, pushCollectionId);
        wrapper.eq(SharePoolWeek::getIsSettle, false);
        return list(wrapper);

    }


    public List<SharePoolWeek> getWaitSettleByType(Long daoId, String yearWeek, AwardsTypeEnum awardsType) {
        LambdaQueryWrapper<SharePoolWeek> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(SharePoolWeek::getDaoId, daoId);
        wrapper.eq(SharePoolWeek::getYearWeek, yearWeek);
        wrapper.eq(SharePoolWeek::getAwardsType, awardsType);
        wrapper.eq(SharePoolWeek::getIsSettle, false);
        return list(wrapper);

    }
}